Skip to content

feat: implement interactive pre-flight checklist for finalize#53

Merged
JacksonFergusonDev merged 6 commits intomainfrom
feat/pre-flight
Feb 24, 2026
Merged

feat: implement interactive pre-flight checklist for finalize#53
JacksonFergusonDev merged 6 commits intomainfrom
feat/pre-flight

Conversation

@JacksonFergusonDev
Copy link
Owner

Context

Executing a blind octopus squash merge directly onto main via git pulsar finalize introduces a high-risk vector for unwanted state mutations. This PR implements the "Pre-Flight Checklists" roadmap item to inject a deterministic, interactive dry-run negotiation phase before any destructive actions or branch switches occur.

Technical Changes

  • Data Acquisition (git_wrapper.py): Introduced diff_shortstat to the GitRepo class. This uses regex capture groups to parse git diff --shortstat, ensuring reliable extraction of files changed, insertions, and deletions even when Git dynamically omits zero-value clauses.
  • Control Flow & UI (ops.py):
    • Hoisted target branch resolution (main vs master) to occur prior to branch switching.
    • Paused the finalize_work execution pipeline to aggregate diff statistics across all remote machine streams.
    • Rendered a rich.table.Table summarizing the incoming DAG changes.
    • Implemented a safe abort path (sys.exit(0)) that guarantees the user's HEAD remains untouched on their active feature branch if they decline the merge.
  • Testing (tests/):
    • Added test_diff_shortstat_regex_parsing to verify regex edge cases.
    • Fixed a mock rendering crash in test_finalize_octopus_merge caused by rich's strict type checking on MagicMock objects.
    • Added test_finalize_aborts_on_user_decline to guarantee isolation of the working directory on abort.
  • Documentation: Updated README.md, src/README.md, and tests/README.md to document the new control flow, highlight the regex determinism, and mark the roadmap item as complete.

Introduces `diff_shortstat` to the `GitRepo` class to wrap `git diff --shortstat`
using regex. This allows for deterministic extraction of files changed, insertions,
and deletions between two revisions without parsing raw patch output.
Halts the `finalize` execution flow prior to the branch switch to display
a `rich` table summary of all candidate backup streams. Aggregates machine
IDs, relative timestamps, and diff statistics to negotiate the merge with
the user. Prevents stranding the user on the target branch if aborted.
Fixes a crash in `test_finalize_octopus_merge` where `rich.table` failed to render
a `MagicMock` object by explicitly returning a string for the commit time. Adds
`test_finalize_aborts_on_user_decline` to ensure clean exits. Expands
`test_git_wrapper.py` with `test_diff_shortstat_regex_parsing` to verify deterministic
data extraction when Git omits empty clauses.
Updates `tests/README.md` to reflect the newly added interactive dry-run logic
for the `finalize` command and the regex parsing determinism in the Git abstraction layer.
Updates `src/README.md` to reflect the newly added interactive dry-run negotiation
for the `finalize` command in the `ops` module, and the regex parsing determinism
added to the Git abstraction layer.
Updates the root README to check off the "Pre-Flight Checklists" item under
the Phase 1 roadmap. Slightly adjusts the `finalize` command description in the
reference table to highlight the new interactive dry-run safety feature.
@JacksonFergusonDev JacksonFergusonDev merged commit 78be704 into main Feb 24, 2026
4 checks passed
@JacksonFergusonDev JacksonFergusonDev deleted the feat/pre-flight branch February 24, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant